package com.zhbcm.treebuilder.common;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2021/2/6 23:24
 */
public class ResultUtil
{
    public static Result success(Object object)
    {
        Result result = new Result();
        result.setCode(CustomResponse.SUCCESS.getCode());
        result.setMsg(CustomResponse.SUCCESS.getMsg());
        result.setData(object);
        return result;
    }

    public static Result success()
    {
        Result result = new Result();
        result.setCode(CustomResponse.SUCCESS.getCode());
        result.setMsg(CustomResponse.SUCCESS.getMsg());
        result.setData(null);
        return result;
    }

    public static Result success(Integer code, String msg, Object obj)
    {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(obj);
        return result;
    }

    public static Result error(Object object)
    {
        Result result = new Result();
        result.setCode(CustomResponse.FAILURE.getCode());
        result.setMsg(CustomResponse.FAILURE.getMsg());
        result.setData(object);
        return result;
    }

    public static Result error()
    {
        Result result = new Result();
        result.setCode(CustomResponse.FAILURE.getCode());
        result.setMsg(CustomResponse.FAILURE.getMsg());
        result.setData(null);
        return result;
    }

    public static Result error(Integer code, String msg, Object obj)
    {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(obj);
        return result;
    }
}
